﻿using PetaPoco;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BrnMall.Manager.Domain.AddressBook
{
    [TableName("crm_Client")]
    [PrimaryKey("Id")]
    public class Clients
    {
        /// <summary>
        /// 我的客户Id
        /// </summary>
        public int Id { get; set; }
        /// <summary>
        /// 销售员的uid
        /// </summary>
        public int Staffid { get; set; }
        /// <summary>
        /// 客户的Uid
        /// </summary>
        public int Uid { get; set; }
        /// <summary>
        /// 备注名
        /// </summary>
        public string MemoName { get; set; }
        /// <summary>
        /// 头像
        /// </summary>
        public string Avatar { get; set; }
        /// <summary>
        /// 性别 0 男 1女
        /// </summary>
        public int Sex { get; set; }
        /// <summary>
        /// 手机
        /// </summary>
        public string Mobile { get; set; }
        /// <summary>
        /// 出生日期
        /// </summary>
        public DateTime Birthday { get; set; }
        /// <summary>
        /// 邮件
        /// </summary>
        public string Email { get; set; }
        /// <summary>
        /// 公司
        /// </summary>
        public string Company { get; set; }
        /// <summary>
        /// 地址
        /// </summary>
        public string Address { get; set; }
        /// <summary>
        /// 会员标签名，多个逗号隔开
        /// </summary>
        public string Tags { get; set; }
        /// <summary>
        /// 客户来源 (1 扫码, 2 转发)
        /// </summary>
        public int Source { get; set; }
        /// <summary>
        /// 备注信息
        /// </summary>
        public string Remark { get; set; }
        /// <summary>
        /// 预计成交日期
        /// </summary>
        public string tradeDate { get; set; }
        /// <summary>
        /// 预计成交概率
        /// </summary>
        public int Probability { get; set; }
        /// <summary>
        /// 最后的跟进时间
        /// </summary>
        public DateTime FollowTime { get; set; }
        /// <summary>
        /// 最后活动时间
        /// </summary>
        public DateTime ActiveTime { get; set; }

        /// <summary>
        /// 名片的展示状态(0 正常,1 屏蔽信息)
        /// </summary>
        public int DisplayState { get; set; }

        /// <summary>
        /// 是否推送消息给业务员（1 推送， 2 不推送）
        /// </summary>
        public int PushState { get; set; }

        /// <summary>
        /// 添加时间
        /// </summary>
        public DateTime Addtime { get; set; }

        public Clients()
        {
            PushState = 1;
            Staffid = Uid = Sex = Source = Probability = 0;
            MemoName = Mobile = Email = Company = Address = Tags = Remark = string.Empty;
        }

        public class ClientView
        {
            public int Id { get; set; }
            /// <summary>
            /// 上级id
            /// </summary>
            public int Staffid { get; set; }
            /// <summary>
            /// 指定标签
            /// </summary>
            public string Tags { get; set; }
            /// <summary>
            /// 预计成交率
            /// </summary>
            public int Probability { get; set; }
            /// <summary>
            /// 用户名称
            /// </summary>
            public string UserName { get; set; }
            /// <summary>
            /// 用户头像
            /// </summary>
            public string Imgs { get; set; }
            /// <summary>
            /// 客户id
            /// </summary>
            public int Uid { get; set; }
            ///// <summary>
            ///// 备注
            ///// </summary>
            //public string Remark { get; set; }
            ///// <summary>
            ///// 最后跟进时间
            ///// </summary>
            public string FollowTime { get; set; }
            ///// <summary>
            ///// 最后活动时间
            ///// </summary>
            //public string ActiveTime { get; set; }
            /// <summary>
            /// 客户来源
            /// </summary>
            public int Source { get; set; }
            /// <summary>
            /// logo
            /// </summary>
            public string Avater { get; set; }
            /// <summary>
            /// 未联系天数
            /// </summary>
            public int NoContactCount { get; set; }
           /// <summary>
           /// 跟进天数
           /// </summary>
            public int FollowUpCount { get; set; }
        }
    }

    public class SalesTopView
    {
        public int StaffId { get; set; }

        public int Uid { get; set; }

        public int Counts { get; set; }

        public string Avater { get; set; }

        public string Name { get; set; }
    }

    /// <summary>
    /// 成交率实体
    /// </summary>
    public class ProbabilityView
    {
        public int Id { get; set; }
        /// <summary>
        /// 成员ID
        /// </summary>
        public int StaffId { get; set; }
        /// <summary>
        /// 预计成交率
        /// </summary>
        public int Probability { get; set; }
    }

    /// <summary>
    /// 时间段统计
    /// </summary>
    public class DayTotalView
    {
        /// <summary>
        /// 日期
        /// </summary>
        public DateTime Date { get; set; }
        /// <summary>
        /// 按日期统计数量
        /// </summary>
        public int Total { get; set; }
    }

    /// <summary>
    /// 标签客户实体
    /// </summary>
    public class ClientTagRelationView
    {
        public int Id { get; set; }
        public int staffId { get; set; }
        public int Uid { get; set; }
        public string MemoName { get; set; }
    }
}